package com.zixuan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zixuan.common.Result;
import com.zixuan.dao.PurchaseApplicationDao;
import com.zixuan.entity.PurchaseApplicationEntity;
import com.zixuan.service.PurchaseApplicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PurchaseApplicationServiceImpl implements PurchaseApplicationService {

    @Autowired
    private PurchaseApplicationDao purchaseApplicationDao;
    @Override
    public Result addPurChaseApplication(PurchaseApplicationEntity purchaseApplicationEntity) {
        return purchaseApplicationDao.insert(purchaseApplicationEntity) >0 ? Result.ok() :Result.err();
    }

    @Override
    public PurchaseApplicationEntity findPurChaseApplicationByPurId(String purId) {

        QueryWrapper<PurchaseApplicationEntity> wrapper = new QueryWrapper<PurchaseApplicationEntity>().eq("pur_id", purId);
        return this.purchaseApplicationDao.selectOne(wrapper);
    }

    @Override
    public Result delPurChaseApplicationByInfoId(String infoId) {

        return this.purchaseApplicationDao.deleteById(infoId)>0 ? Result.ok() :Result.err();
    }
}
